﻿/**
   ActionScript Class File -- Created with SAPIEN Technologies PrimalScript 3.1
   
   @class  
   @package
   @author Colin Leung
   @codehint 
   @example 
   @tooltip 
*/


class com.mixmedia.control.TextFieldScrollArrow extends MovieClip{
	public var target_txt;
	public var arrowType:String;//scrollUp, scrollDown
	public var scrollInterval_array:Array;

	public function TextFieldScrollArrow(){// naming method: txt_ScrollUp
		scrollInterval_array = new Array();
		getArrowType();
		getTargetTxt();
	};

	public function getArrowType(){
		arrowType = this._name.split("~")[1];
		return arrowType;
	};

	public function getTargetTxt(){
		var textFieldName = this._name.split("~")[0];
		target_txt = eval(_parent+"."+textFieldName);
		return target_txt;
	};

	public function onPress(){
		clearScroll();
		scrollInterval_array.push(setInterval(this,"scrollTxt",50));
	}

	public function onRelease(){
		clearScroll();
	}
	
	public function onRollOut(){
		clearScroll();
	}
	
	public function onDragOut(){
		clearScroll();
	}	
	
	public function clearScroll(){
		var i;
		for(i=0;i<scrollInterval_array.length;i++){
			var intervalID = scrollInterval_array.pop();
			clearInterval(intervalID);
		}		
	};

	public function scrollTxt(){
		if(arrowType == "scrollUp"){
			target_txt.scroll--;
		}else{
			target_txt.scroll++;
		}
	}
}
